home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / e / amigae21b.lha / Amiga_E_v2.1b / Sources / Utilities / SuperVisor.e < prev    next >
Text File  |  1992-09-02  |  5KB  |  165 lines

  1. /* A system monitor written in E. It does't perform any very special
  2.    functions, can be a neat addition to Xoper or ARTM, however.
  3.    BUG: doesn't display processes that run on the process-structure of
  4.    another process       */
  5.  
  6. ENUM TASKS,LIBRARIES,DEVICES,PORTS,WINDOWS
  7. CONST GFXOFFSET=40, BUFSIZE=GADGETSIZE*5
  8.  
  9. /* we search for our os-variables the clean way, so we need a lot
  10.    of modules ... */
  11.  
  12. MODULE 'intuition/intuition', 'exec/execbase', 'exec/lists',
  13.        'exec/libraries', 'exec/nodes', 'exec/tasks', 'exec/ports',
  14.        'intuition/intuitionbase', 'intuition/screens'
  15.  
  16. DEF glist[BUFSIZE]:ARRAY,window,gad=TASKS,
  17.     exec:PTR TO execbase,list:PTR TO lh
  18.  
  19. PROC main()
  20.   DEF next,class,object:PTR TO gadget
  21.   next:=Gadget(glist,NIL,TASKS,0,5,2,80,'Tasks')
  22.   next:=Gadget(next,glist,LIBRARIES,0,90,2,80,'Libraries')
  23.   next:=Gadget(next,glist,DEVICES,0,175,2,80,'Devices')
  24.   next:=Gadget(next,glist,PORTS,0,260,2,80,'Ports')
  25.   next:=Gadget(next,glist,WINDOWS,0,345,2,80,'Windows')
  26.   window:=OpenW(0,11,640,245,$242,$140F,'Amiga SuperVisor',0,1,glist)
  27.   IF window<>NIL
  28.     exec:=execbase
  29.     displaylist(gad)
  30.     WHILE (class:=WaitIMessage(window))<>IDCMP_CLOSEWINDOW
  31.       IF class=IDCMP_GADGETUP
  32.         object:=MsgIaddr()
  33.         gad:=object.userdata
  34.       ENDIF
  35.       displaylist(gad)       /* for GADGETUP and RESIZE */
  36.     ENDWHILE
  37.     CloseW(window)
  38.   ENDIF
  39. ENDPROC
  40.  
  41. PROC displaylist(gad)
  42.   DEF funcs:PTR TO LONG
  43.   funcs:=[`displaytasks(),`displaylibraries(),`displaydevices(),
  44.           `displayports(),`displaywindows()]
  45.   Eval(funcs[gad])
  46. ENDPROC
  47.  
  48. PROC initdisplay(string)
  49.   Move(stdrast,0,GFXOFFSET-18)
  50.   ClearScreen(stdrast)
  51.   Colour(1,0)
  52.   TextF(5,GFXOFFSET-12,string)
  53.   Colour(2,0)
  54. ENDPROC
  55.  
  56. PROC displaytasks()
  57.   DEF tlist:PTR TO tc,tlist2:PTR TO tc,off=GFXOFFSET,node:PTR TO ln
  58.   initdisplay('Taskname                Pri  Sig         Stack')
  59.   Forbid()
  60.   list:=exec.taskwait
  61.   tlist2:=list.head
  62.   list:=exec.taskready
  63.   tlist:=list.head
  64.   WHILE tlist
  65.     node:=tlist
  66.     IF node.succ
  67.       TextF(5,off,'\l\s[20]  \r\d[5]  $\z\h[8]  \r\d[6]',
  68.         node.name,node.pri,tlist.sigwait,tlist.spupper-tlist.splower)
  69.       off:=off+8
  70.     ENDIF
  71.     tlist:=node.succ
  72.     IF (tlist=NIL) AND (tlist2<>NIL)
  73.       tlist:=tlist2
  74.       tlist2:=NIL
  75.       IF off<>GFXOFFSET THEN off:=off+4
  76.     ENDIF
  77.   ENDWHILE
  78.   Permit()
  79. ENDPROC
  80.  
  81. PROC displaylibraries()
  82.   DEF llist:PTR TO lib,off=GFXOFFSET,node:PTR TO ln
  83.   initdisplay('Libraryname                  Pri   Version  OpenCnt')
  84.   Forbid()
  85.   list:=exec.liblist
  86.   llist:=list.head
  87.   WHILE llist
  88.     node:=llist
  89.     IF node.succ
  90.       TextF(5,off,'\l\s[25]  \r\d[5]  \d[3].\l\d[4]  \d[3]',
  91.         node.name,node.pri,llist.version,llist.revision,llist.opencnt)
  92.       off:=off+8
  93.     ENDIF
  94.     llist:=node.succ
  95.   ENDWHILE
  96.   Permit()
  97. ENDPROC
  98.  
  99. PROC displaydevices()
  100.   DEF dlist:PTR TO lib,off=GFXOFFSET,node:PTR TO ln
  101.   initdisplay('Devicename                   Pri   Version  OpenCnt')
  102.   Forbid()
  103.   list:=exec.devicelist
  104.   dlist:=list.head
  105.   WHILE dlist
  106.     node:=dlist
  107.     IF node.succ
  108.       TextF(5,off,'\l\s[25]  \r\d[5]  \d[3].\l\d[4]  \d[3]',
  109.         node.name,node.pri,dlist.version,dlist.revision,dlist.opencnt)
  110.       off:=off+8
  111.     ENDIF
  112.     dlist:=node.succ
  113.   ENDWHILE
  114.   Permit()
  115. ENDPROC
  116.  
  117. PROC displayports()
  118.   DEF plist:PTR TO mp,taskname,portname,off=GFXOFFSET,node:PTR TO ln,t:PTR TO ln
  119.   initdisplay('Portname                   Pri    Bit#    Task')
  120.   Forbid()
  121.   list:=exec.portlist
  122.   plist:=list.head
  123.   WHILE plist
  124.     node:=plist
  125.     IF node.succ
  126.       portname:=node.name
  127.       IF (portname<>NIL) AND (portname[]<>0)
  128.         t:=plist.sigtask
  129.         taskname:=t.name
  130.         IF taskname=NIL THEN taskname:='-'
  131.         TextF(5,off,'\l\s[25]  \d[5]  \d[5]   \s[20]',
  132.           node.name,node.pri,plist.sigbit,taskname)
  133.         off:=off+8
  134.       ENDIF
  135.     ENDIF
  136.     plist:=node.succ
  137.   ENDWHILE
  138.   Permit()
  139. ENDPROC
  140.  
  141. PROC displaywindows()
  142.   DEF slist:PTR TO screen,wlist:PTR TO window,
  143.       off=GFXOFFSET,intui:PTR TO intuitionbase
  144.   Forbid()
  145.   intui:=intuitionbase
  146.   initdisplay('Windowname               Width Height  IDCMP      FLAGS')
  147.   slist:=intui.firstscreen
  148.   WHILE slist
  149.     Colour(3,0)
  150.     TextF(5,off,'\l\s[25]  \d[5]  \d[3]',
  151.       slist.title,slist.width,slist.height)
  152.     Colour(2,0)
  153.     off:=off+8
  154.     wlist:=slist.firstwindow
  155.     WHILE wlist
  156.       TextF(5,off,'\l\s[25]  \d[5]  \d[3]  $\z\r\h[8]  $\z\r\h[8]',
  157.       wlist.title,wlist.width,wlist.height,wlist.idcmpflags,wlist.flags)
  158.       wlist:=wlist.nextwindow
  159.       off:=off+8
  160.     ENDWHILE
  161.     slist:=slist.nextscreen
  162.   ENDWHILE
  163.   Permit()
  164. ENDPROC
  165.